//package com.tree.common.config.jdbc;
//
//import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.aop.aspectj.AspectJExpressionPointcut;
//import org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//import org.springframework.transaction.annotation.EnableTransactionManagement;
//import org.springframework.transaction.interceptor.TransactionInterceptor;
//
//import javax.sql.DataSource;
//import java.util.Properties;
//
///**
// * @ClassName com.demo.common.config.jdbc
// * Description: <类功能描述>. <br>
// * <p>
// * <使用说明>
// * </p>
// * @Author tree
// * @Date 2019-05-25 00:20
// * @Version 1.0
// */
//@Configuration
//@EnableTransactionManagement(proxyTargetClass = true)
//@MapperScan(basePackages = {"com.tree.**.mapper"})
//public class DataSourceConfig {
//    private static final String POINTCUTS_EXPRESSION = "execution(* com.tree.**.service.**.*(..))";
//
//    @Bean
//    public DataSourceTransactionManager transactionManager(DataSource datasource){
//        DataSourceTransactionManager transactionManager = new DataSourceTransactionManager();
//        transactionManager.setDataSource(datasource);
//        transactionManager.setDefaultTimeout(25);
//        return transactionManager;
//    }
//
//    @Bean
//    public TransactionInterceptor txAdvice(DataSourceTransactionManager transactionManager){
//        TransactionInterceptor txAdvice = new TransactionInterceptor();
//        txAdvice.setTransactionManager(transactionManager);
//        Properties transactionAttribute = new Properties();
//        transactionAttribute.setProperty("get*","PROPAGATION_NOT_SUPPORTED");
//        transactionAttribute.setProperty("sel*","PROPAGATION_NOT_SUPPORTED");
//        transactionAttribute.setProperty("query*","PROPAGATION_NOT_SUPPORTED");
//        transactionAttribute.setProperty("*","PROPAGATION_REQUIRED");
//        txAdvice.setTransactionAttributes(transactionAttribute);
//        return txAdvice;
//    }
//    @Bean
//    public AspectJExpressionPointcut interceptorPointcuts(){
//        AspectJExpressionPointcut interceptorPointcuts = new AspectJExpressionPointcut();
//        interceptorPointcuts.setExpression(POINTCUTS_EXPRESSION);
//        return interceptorPointcuts;
//    }
//
//    @Bean
//    public DefaultBeanFactoryPointcutAdvisor txAdvisor(TransactionInterceptor txAdvice){
//        DefaultBeanFactoryPointcutAdvisor txAdvisor = new DefaultBeanFactoryPointcutAdvisor();
//        txAdvisor.setAdvice(txAdvice);
//        txAdvisor.setPointcut(interceptorPointcuts());
//        return txAdvisor;
//    }
//
//    /**
//     * 处理分页
//     */
////    @Bean
////    public PaginationInterceptor paginationInterceptor(){
////        return new PaginationInterceptor();
////    }
//
//
//}
